<?php

include_once('../@base/database.php');

$sql = "SELECT * FROM oprec_rectify_record";
$result = exec_sql($sql);
foreach ($result as $line) {
  $number = $line['number'];
  
  $clientName = $line['clientName'];
  $sql = "SELECT * FROM oprec_security_data WHERE name = '{$clientName}'";
  // echo '<br />' . $sql . '<br />';
  $clientRank;
  $res = exec_sql($sql);
  var_export($res);
  if ($res) {
    $clientRank = $res[0]['clientRank'];
  }
  echo '<br />';

  $userName = $line['userName'];
  $sql = "SELECT * FROM oprec_security_data WHERE name = '{$userName}'";
  // echo '<br />' . $sql . '<br />';
  $userGroup;
  $userOffice;
  $res = exec_sql($sql);
  var_export($res);
  if ($res) {
    $userGroup = $res[0]['clientGroup'];
    $userOffice = $res[0]['clientOffice'];
  }
  echo '<br />';
  $sql = "UPDATE oprec_rectify_record SET clientRank='{$clientRank}', userGroup='{$userGroup}', userOffice='{$userOffice}', seat='其他', sector='其他' WHERE number={$number}";
  echo '<br />' . $sql . '<br />';
  var_export(exec_sql($sql));
  echo '<br /><br />';
}
